<template>
  <view class="register-container">
    <view class="logo">
      <image
        src="https://zhengxin-pub.cdn.bcebos.com/mark/5b7250fd09b617c8dcc323cab6f58693.jpg"
      />
    </view>
    <view class="register-form">
      <input
        v-model="form.phone"
        class="input"
        type="text"
        placeholder="请输入手机号码"
        @blur="validatePhone"
      />
      <view class="verification-container">
        <input
          v-model="form.verificationCode"
          class="input"
          type="text"
          placeholder="请输入验证码"
        />
        <button @tap="sendVerificationCode" class="code-button">发送验证码</button>
      </view>
      <button @tap="onRegister" class="button">注册</button>
      <view class="links">
        <text @click="goToLogin">已有账号？登录</text>
      </view>
    </view>
  </view>
</template>
<script setup>
import { ref } from 'vue';

const form = ref({
  phone: '',
  verificationCode: ''
});

const sendVerificationCode = () => {
  // Logic to send verification code to the phone number
  console.log('Sending verification code to:', form.value.phone);
};

const onRegister = () => {
  // Registration logic here
  console.log('Registering with:', form.value);
};


//跳转登录
function goToLogin() {
  uni.navigateTo({
    url: '/pages/login/login'
  });
}

</script>

<style lang="scss">
.register-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;

  .logo {
    margin-bottom: 30px;
  }

  .register-form {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;

    .input {
      width: 100%;
      height: 45px;
      margin-bottom: 20px;
      padding: 10px;
      border: 1px solid #ddd;
      border-radius: 5px;
      font-size: 16px;
    }

    .verification-container {
      display: flex;
      justify-content: space-between;

      .code-button {
        height: 45px;
        background-color: #28bb9c;
        color: #fff;
        border: none;
        border-radius: 5px;
        font-size: 16px;
        cursor: pointer;
        width: 30%; /* Adjust width as needed */
      }
    }

    .button {
      height: 50px;
      background-color: #28bb9c;
      color: #fff;
      border: none;
      border-radius: 10px;
      font-size: 20px;
      cursor: pointer;
      margin-top: 20px;
    }

    .links {
      display: flex;
      justify-content: center;
      margin-top: 10px;
      font-size: 14px;
      color: #007aff;

      text {
        cursor: pointer;
      }
    }
  }
}
</style>


